<template>
	<view class="goods-cate">
		<u-navbar :is-fixed="true" :border-bottom="false" :background="{ background: 'transparent' }" :is-back="false">
			<template>
				<view class="u-p-l-20 bold nr page-title">
					懒猫校园生活
				</view>
			</template>
		</u-navbar>
		<view v-if="shopInfo.name">
			<router-link to="/pages/goods_search/goods_search">
				<view class="header">
					<u-search wrapBgColor="transparent" bg-color="#FFFFFF" :disabled="true"></u-search>
				</view>
			</router-link>
			<!-- 轮播 -->
			<view class="content" v-if="appConfig.cate_style == 1 || appConfig.cate_style == 4">
				<cate-two :cate-list="cateList"></cate-two>
			</view>
			<view class="content" v-if="appConfig.cate_style == 3 || appConfig.cate_style == 2">
				<cate-one :cate-list="cateList"></cate-one>
			</view>
		</view>
		<view class="flex flex-col" style="padding-top: 30vh;" v-else>
			<u-icon name="map" size="90" color="#999999"></u-icon>
			<view class="u-m-b-35" style="font-weight: bold;color: #999999;font-size: 40rpx;">
				请选择学院
			</view>
			<navigator url="/bundle/pages/store_list/store_list" class="u-m-t-15" style="width:60vw;color: #999999;border: 1px solid #999999;border-radius: 100rpx;line-height: 40px;text-align: center;">
				选择学院
			</navigator>
		</view>
		<tabbar></tabbar>
	</view>
</template>

<script>
	import {
		getLevelOneList,
		getGoodsList,
		getListByLevelOne
	} from '@/api/store';
	import {
		getRect,
		trottle,
		arraySlice
	} from '@/utils/tools';
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	import Cache from '@/utils/cache'
	export default {
		data() {
			return {
				shopInfo:{},
				cateList: [],
				cateTwoList: [],
				selectIndex: 0
			};
		},
		async onLoad(options) {
			// this.getListByLevelOneFun()
		},
		onShow() {
			this.getCartNum()
			this.shopInfo = uni.getStorageSync('selectStoreInfo')
			if(this.shopInfo && this.cateList.length <= 0)this.getLevelOneListFun();
		},
		methods: {
			...mapActions(['getCartNum']),
		

			async getLevelOneListFun() {
				const {
					code,
					data
				} = await getLevelOneList();
				if (code == 1) {
					this.cateList = data
				}
			},
			
		},
		computed: {
			...mapGetters(['inviteCode', 'appConfig']),
		}
	};
</script>
<style lang="scss" scoped>
	$header-height: 94rpx;
	
	.page-title{
		color: #000;
	}

	page {
		background-color: #fbfbfb;
		height: 100%;
		.goods-cate {
			height: 100%;
			background: linear-gradient(to bottom, #f6dcdf ,#f8f8f8 235px);
			.header {
				box-sizing: border-box;
				height: $header-height;
				border-bottom: $-solid-border;

				.search {
					flex: 1;
					height: 60rpx;

					input {
						flex: 1;
						height: 100%;
					}
				}
			}

			.content {
				height: calc(100vh - 91px  - 228rpx  - #{$header-height} - var(--window-top) - var(--window-bottom) - 50px - env(safe-area-inset-bottom));
			}
		}
	}
</style>
